package sentinel;


import java.util.UUID;

//多窗口购票
public class Test {
    private static  int  ticks = 1000;
    public static void main(String[] args) throws InterruptedException {
            final Integer a = 10;
        Thread thread1 = new Thread(new Runnable() {
         @Override
         public void run() {
             synchronized(this) {
                 while(ticks > 0){
                     ticks--;
                     System.out.println("1-" + ticks);
                 }
             }

         }
     });
     Thread thread2 = new Thread(new Runnable() {
         @Override
         public void run() {
             synchronized (this){
                 while(ticks > 0){
                     ticks--;
                     System.out.println("2-" + ticks);
                 }
             }
         }
     });
     thread1.start();
     thread2.start();
       Thread.sleep(1000L);
        System.out.println(ticks);
    }
}
